<%@ page import="com.conversationboard.model.*" %>
<%@ page import="com.conversationboard.view.*" %>
<%@ page import="com.conversationboard.config.*" %>
<%@ page import="java.security.Principal" %>
<%@ page import="com.conversationboard.controller.confirm.Confirm" %>

<%@page pageEncoding="UTF-8"%>
<%@page contentType="text/html;charset=UTF-8"%>

<%
    Principal principal = request.getUserPrincipal();
    String userName = null;
    
    if (principal!=null) {
    	userName = principal.getName();
    }
   
 	User user = User.get(userName);
 	
 	String toBeBannedLoginId = request.getParameter("userid");
 	int boardId = Integer.parseInt(request.getParameter("boardid"));
 	
 	User toBeBanned = User.get(toBeBannedLoginId);
 	request.setAttribute("toBeBanned", toBeBanned);
 	
%>


<html>

	<head>
		<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
		<title>Ban User</title>
		<link rel="stylesheet" type="text/css" href="<%=Configuration.getInstance().getRoot()%>/Stylesheets/<%=StyleSheets.getStyleSheetFileName(request.getCookies())%>"/>
	</head>

	<body>
	
		<%= MainMenu.display(request.getUserPrincipal()) %>

		<div class="headingblock">
			<h1>Ban User</h1>
		</div>

		<div class="mainblock">
			
			<form class="formsection" action="<%=Configuration.getInstance().getRoot()%>/Admin/AdminBanControllerServlet" method="post">

			 	<%= Confirm.getKey(request.getUserPrincipal().getName()) %>

				<p><strong>Ban the following user:</strong></p>
			 	
				<table class="table">
					<tr class="row">
						<td class="header">Login ID</td>
						<td class="cell">${toBeBanned.loginId}</td>
					</tr>
	
					<tr class="row">
						<td class="header">Display Name</td>
						<td class="cell">${toBeBanned.fullDisplayName}</td>
					</tr>
	
					<tr class="row">
						<td class="header">Timezone</td>
						<td class="cell">${toBeBanned.preferences.timeZoneString}</td>
					</tr>
	
					<tr class="row">
						<td class="header">Registration Date</td>
						<td class="cell">${toBeBanned.creationDate}</td>
					</tr>

					<tr class="row">
						<td class="header">Login Count</td>
						<td class="cell">${toBeBanned.loginCount}</td>
					</tr>
	
					<tr class="row">
						<td class="header">Last Accessed</td>
						<td class="cell">${toBeBanned.lastAccessedString} (${toBeBanned.lastAccessed})</td>
					</tr>
	
					<tr class="row">
						<td class="header">IP Address</td>
						<td class="cell">${toBeBanned.ipAddress}</td>
					</tr>

					<tr class="row">
						<td class="header">Host Name</td>
						<td class="cell">${toBeBanned.hostName}</td>
					</tr>
				</table>
		
				<br />
		
				<p><strong>If you select a board, the user will be banned from that board:</strong>
					<%= BoardDisplay.displayDropDown(user) %>
				</p>
				

				<p>				
					<label for='checkbox'>Temporary Ban:</label>
					<input type='checkbox' name='checkbox' value='temporary' />
				</p>
		
				<input name="boardid" value="<%= boardId %>" type="hidden" />
				<input name="loginid" value="<%= toBeBannedLoginId %>" type="hidden" />
		
				<br /><p><input type="submit" value="    OK    " /></p>
		
			</form>

		</div>

		<!--<script src="http://www.google-analytics.com/urchin.js" type="text/javascript"></script>-->
		<!--<script type="text/javascript">_uacct = "UA-1148679-1";urchinTracker();</script>--> 

	</body>
	
</html>
